﻿using Dm.util;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataCollection.Core.Models
{
    /// <summary>
    /// 
    ///</summary>
    [SugarTable("c_history_data")]
    public class HistoryDataModel
    {
        #region 属性
        /// <summary>
        /// 备  注:编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "history_number")]
        public long HistoryNumber { get; set; }

        /// <summary>
        /// 备  注:近端压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_pressure")]
        public double MainPressure { get; set; }

        /// <summary>
        /// 备  注:近端介质温度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_medium_temperature")]
        public double MainMediumTemperature { get; set; }

        /// <summary>
        /// 备  注:近端电池
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_battery")]
        public double MainBattery { get; set; }

        /// <summary>
        /// 备  注:远端压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_pressure")]
        public double RemotePressure { get; set; }

        /// <summary>
        /// 备  注:远端介质温度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_medium_temperature")]
        public double RemoteMediumTemperature { get; set; }

        /// <summary>
        /// 备  注:远端电池
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_battery")]
        public double RemoteBattery { get; set; }

        /// <summary>
        /// 备  注:时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "time")]
        public long Time { get; set; }
        #endregion

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            List<HistoryDataModel> list = new List<HistoryDataModel>();
            list.Add(this);
            int res = SqlSugarHelper.Insertable<HistoryDataModel>(list);
            return res;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            List<HistoryDataModel> list = new List<HistoryDataModel>();
            list.Add(this);
            int res = SqlSugarHelper.Deleteable<HistoryDataModel>(list);
            return res;
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        public int Update()
        {
            List<HistoryDataModel> list = new List<HistoryDataModel>();
            list.Add(this);
            int res = SqlSugarHelper.Updateable<HistoryDataModel>(list);
            return res;
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<HistoryDataModel> List(Dictionary<string, object> where)
        {

            return SqlSugarHelper.Inquireable<HistoryDataModel>(where);
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<HistoryDataModel> ListPage(Dictionary<string, object> where, int page, int pageSize, ref int totalCount)
        {
            return SqlSugarHelper.InquireableToPageList<HistoryDataModel>(where, page, pageSize, ref totalCount);
        }
    }
}
